/**
 * @file rlog.h
 *
 * @copyright This file creat by rensuiyi ,all right reserve!
 *
 * @author rensuyi
 *
 * @date 2013/12/21 11:37:49
 */
#ifndef __RLOG_H__
#define __RLOG_H__

#ifdef __cplusplus
extern "C"
{
#endif /*__cplusplus */

#include <stdint.h>
// The definition of the rlog level
#define  RLOG_NONE          (15)
#define  RLOG_USER          (14)
#define  RLOG_FAULT         (13)
#define  RLOG_ERROR         (12)
#define  RLOG_WARN          (11)
#define  RLOG_MESSAGE       (10)
#define  RLOG_INFO          (9)
#define  RLOG_ALL           (1)

typedef int (* rlog_stream_t)(const char* buf, int len);

extern int rlog_init(rlog_stream_t stream, uint8_t level);
extern uint8_t rlog_set_level(uint8_t level);
extern uint8_t rlog_get_level(uint8_t level);
extern rlog_stream_t rlog_set_stream(rlog_stream_t stream);
extern rlog_stream_t rlog_get_stream(void);
extern void rlog(uint8_t level, char* fmt, ...);  //!< __attribute__((format (printf, 2, 3)));

#define  rlog_u(fmt,args...)      rlog(RLOG_USER,fmt,##args)
#define  rlog_i(fmt,args...)      rlog(RLOG_INFO,"[INFO]"fmt"\r\n",##args)
#define  rlog_m(fmt,args...)      rlog(RLOG_MESSAGE,"[MESSAGE]"fmt"\r\n",##args)
#define  rlog_w(fmt,args...)      rlog(RLOG_WARN,"[WARN]"fmt"\r\n",##args)
#define  rlog_e(fmt,args...)      rlog(RLOG_ERROR,"[ERROR]"fmt"\r\n",##args)

#ifdef __cplusplus
}
#endif /*__cplusplus */
#endif /* __SL_RLOG_H__ */
